public getINIString( filename[], section[], item[], result[] ) {
  new File:inifile;
  new line[512];
  new sectionstr[64], itemstr[64];
  new sectionfound = 0;
 
  inifile = fopen( filename, io_read );
  if( !inifile ) {
    printf( "FATAL: Couldn't open \"%s\"!", hdpath );
    return 0;
  }
 
  format( sectionstr, 64, "[%s]", section );
  format( itemstr, 64, "%s=", item );
 
  while( fread( inifile, line )) {
    line[strlen( line )-2] = 0; /* Remove \r\n */
 
    if( line[0] == 0 ) {
      continue;
    }
 
    /* If !sectionfound is true, we're looking for the proper section. */
    if( !sectionfound ) {
      /* Check if wanted section is being opened. */
      if( !strcmp( line, sectionstr, true, strlen( sectionstr ))) {
        sectionfound = 1;
      }
    }
    else { /* Itemmode from here. */
      /* We're leaving the wanted section and didn't find the value yet.
       * So we'll never reach it. */
      if( line[0] == '[' ) {
        return 0;
       }
 
      /* Have we reached our wanted INI item? */
      if( !strcmp( line, itemstr, true, strlen( itemstr ))) {
        format( result, sizeof( line ), "%s", line[strlen( itemstr )] );
        return 1;
      }
    }
  }
 
  fclose( inifile );
  return 0;
}

public getINIStringDefault( filename[], section[], item[], defval[], result[] ) {
  new retval;
 
  retval = getINIString( filename, section, item, result );
  if( !retval ) {
    format( result, strlen( defval ), defval );
  }
 
  return retval;
}